var majorityElement = function (nums) {
  let len2 = nums.length / 2;
  let len = nums.length;
  let num;
  let hashTable = {};

  for (let i = 0; i < len; i++) {
    if (hashTable[nums[i]] !== undefined) {
      hashTable[nums[i]]++;
    } else {
      hashTable[nums[i]] = 1;
    }

    if (hashTable[nums[i]] > len2) {
      return nums[i];
    }
  }
};
